﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
using COM.Rights.Model;
using COM.Rights.BLL;
using System.Data;

public partial class FrontPages_UserControl_Review : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            //InitReviewsList("");
        }
    }

    protected void aspNetPage_PageChanged(object sender, EventArgs e)
    {
        this.InitReviewsList("");
    }

    public string StyleName
    {
        get
        {
            return CssControler.GetCssFileNameByHost(HostName);
        }
    } 



    private string _HostName;
    public string HostName
    {
        get
        {
            if (StringHelper.FormatObjToString(ViewState["HostName"]) != string.Empty)
            {
                return StringHelper.FormatObjToString(ViewState["HostName"]);
            }
            else if (!string.IsNullOrEmpty(hidHostName.Value))
            { ViewState["HostName"] = hidHostName.Value; return hidHostName.Value; }

            return this._HostName;
        }
        set
        {
            ViewState["HostName"] = value;
        }
    }


    private int _PageSize;
    public int PageSize
    {
        set
        {
            aspNetPage.PageSize = value==0?9:value;
        }
    }

 


    public void InitReviewsList(string area) {
        //HostName = "www.39ceping.com";
        BdReviews _BdReviews = new BdReviews();
        List<System.DBParameter> _listDBParameter = new List<System.DBParameter>();
        int? i = 0;
        string filter = string.Empty;
        if (string.IsNullOrEmpty(area))
        {
            filter = " HostName LIKE '%{0}%' AND IsDelete = 0  AND  IsPublish = 1";
        }
        else {
            filter = " HostName LIKE '%{0}%' AND IsDelete = 0  AND  IsPublish = 1 AND area = '" + area + "'";
        }
        DataTable dt = _BdReviews.GetDataTable(this.aspNetPage.CurrentPageIndex, aspNetPage.PageSize, ref i, "CustomerName,Content,Reply,ReviewDate", string.Format(filter, HostName), "ReviewDate DESC, GID", _listDBParameter);
        this.aspNetPage.RecordCount = (int)i;
        this.aspNetPage.DataBind();
        this.repMessageList.DataSource = dt;
        this.repMessageList.DataBind();
        
    }

}